<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
  <script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
</head>
<body>
<h1>Qianfan Chat</h1>
<div id="main">
 <ul id="chat">
  <li>你好，我是AI助手</li>
  </ul>
  <div id="input">
   <input type="text" id="message" placeholder="请输入内容"/>
  <button id="sendButton">发送</button>
</div>
</div>

<script>
  $(document).ready(function () {
    $("#sendButton").click(function () {
      var message = $("#message").val();
      $("#chat").append("<li>我说：" + message + "</li>");
      $.get("http://127.0.0.1:8080/chat", {message: message}, function (data) {
        $("#chat").append("<li>AI说：" + data.result + "</li>");
      });
      $("#message").val(""); // 清空输入框内容
    });
  });
</script>
</body>
</html>